package com.owc.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @Author xiaom
 * @Date 2020/2/25 13:46
 * @Version 1.0.0
 * @Description <>
 **/
public enum CycleType {

    DAY_TYPE(10,"天"),
    YEAR_TYPE(20,"年");

    CycleType(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    private Integer type;

    private String desc;

    public Integer getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }

    public static Optional<CycleType> match(Integer type){
        return Arrays.stream(CycleType.values())
                .filter(t -> t.getType().equals(type))
                .findFirst();
    }
}
